package com.wl.springsecuritystudy.controller;

import com.wl.springsecuritystudy.controller.dto.LoginDTO;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Stack;
import java.util.stream.Collectors;

@RestController
public class TestController {

    @GetMapping("/login")
    public LoginDTO test(LoginDTO loginDTO){
        Stack<String> stack = new Stack<>();

        stack.push("hello");

        return loginDTO;
    }

    public static void rotate(int[] nums, int k) {
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < nums.length; i++) {
            stack.push(nums[i]);

        }
        for (int i = nums.length-1-k; i >= 0; i--) {
            nums[i+k]=nums[i];
        }
        System.out.println(Arrays.stream(nums).mapToObj(String::valueOf).collect(Collectors.joining(",")));
        for (int i = k-1; i >= 0; i--) {
            nums[i]=stack.pop();
        }
        System.out.println(Arrays.stream(nums).mapToObj(String::valueOf).collect(Collectors.joining(",")));


    }

    public static void main(String[] args) {

        int[] nums = {1,2,3,4,5,6,7};

        TestController.rotate(nums,3);

    }

}
